package org.mobai.flow.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author mobai
 */
@AllArgsConstructor
@Getter
public enum OperatorEnum {
    AND("and", " && ", "和"),
    OR("or", " || ", "或"),


    EQUAL("eq", " == ", "等于"),

    NOT_EQUAL("ne", " != ", "不等于"),
    GREATER_THAN("gt", " > ", "大于"),
    GREATER_THAN_OR_EQUAL("ge", " >= ", "大于等于"),
    LESS_THAN("lt", " <= ", "小于"),
    LESS_THAN_OR_EQUAL("le", " <= ", "小于等于");

    private final String type;
    private final String value;
    private final String desc;

    private static final Map<String, OperatorEnum> OPERATOR_ENUM_MAP = new HashMap<>();

    static {
        for (OperatorEnum value : OperatorEnum.values()) {
            OPERATOR_ENUM_MAP.put(value.getType(), value);
        }
    }

    public static OperatorEnum getByType(String type) {
        return OPERATOR_ENUM_MAP.get(type);
    }

}
